class Computer:
    def __init__(self, brand, color, memory_size):
        self.brand = brand
        self.color = color
        self.memory_size = memory_size

    def play_game(self):
        print(f"This {self.color} {self.brand} computer with {self.memory_size}GB memory is playing a game.")

    def code(self):
        print(f"This {self.color} {self.brand} computer with {self.memory_size}GB memory is coding.")

    def watch_video(self):
        print(f"This {self.color} {self.brand} computer with {self.memory_size}GB memory is watching a video.")
class Dog:
    def __init__(self, name, color, age):
        self.name = name
        self.color = color
        self.age = age

    def bark(self):
        print(f"{self.name} is barking.")

class Person:
    def __init__(self, name, age, dog=None):
        self.name = name
        self.age = age
        self.dog = dog

    def walk_dog(self):
        if self.dog is not None:
            print(f"{self.name} is walking with the dog named {self.dog.name}.")
            self.dog.bark()
        else:
            print(f"{self.name} doesn't have a dog to walk with.")
class Student:
    def __init__(self, name, age, student_id):
        self.name = name
        self.age = age
        self.student_id = student_id

    def attend(self):
        print(f"{self.name} 到")

    def print_info(self):
        print(f"Name: {self.name}, Age: {self.age}, ID: {self.student_id}")

class Classroom:
    def __init__(self, class_name):
        self.students = []
        self.class_name = class_name

    def add_student(self, student):
        self.students.append(student)

    def remove_student(self, student):
        if student in self.students:
            self.students.remove(student)

    def roll_call(self):
        for student in self.students:
            student.attend()

    def calculate_average_age(self):
        if not self.students:
            return 0
        return sum(student.age for student in self.students) / len(self.students)
def input_age():
    while True:
        try:
            age = int(input("请输入您的年龄 (1-100): "))
            if 1 <= age <= 100:
                print(f"您输入的年龄是 {age}")
                break
            else:
                print("年龄应该在 1 到 100 之间，请再次尝试。")
        except ValueError:
            print("无效输入！请输入一个整数。")
# 创建人的对象小明和他的狗大黄
xiaoming = Person('小明', 30)
da_huang = Dog('大黄', '黄色', 3)

# 让小明拥有一条狗大黄
xiaoming.dog = da_huang

# 让小明去遛大黄
xiaoming.walk_dog()